home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mush-7.1.1 / digestify < prev    next >
Encoding:
Text File  |  1990-05-02  |  3.4 KB  |  142 lines

  1. #! ../bin/mush -F!
  2. #
  3. # Mush digestifier.  Makes a folder or a list of messages into a digest.
  4. #
  5. # A "digest" is a collection of E-mail messages bundled together into a
  6. # single message for ease of redistribution.  The individual messages
  7. # in the digest are called "articles".  Each article has a small set of
  8. # essential headers (usually From:, Date:, and Subject:) and is divided
  9. # from the preceding and following articles by an "article separator"
  10. # string (usually eight hyphens, "--------").  The Mush built-in command
  11. # "undigest" unpacks most digests, including those made by this script.
  12. #
  13. # Usage:
  14. #  From your shell:        digestify -f mailbox
  15. #  From within mush:    
  16. #    First:        cmd digest "set digest = '\!*' ; source digestify"
  17. #    Then:        digest [msg-list]
  18. #    Or:        message-selection-command | digest
  19. #
  20. # Note that by default it makes a digest of the ENTIRE folder!
  21. #
  22.  
  23. #
  24. # Rudimentary sanity checks
  25. #
  26. if ! $?version
  27.     echo "You must have Mush version 7.0 or higher to run this script"
  28.     exit
  29. endif
  30. if ! $?thisfolder
  31.     echo "You can't use this script as an init file; try using -F"
  32.     exit
  33. endif
  34.  
  35. #
  36. # Set up defaults
  37. #
  38. if ! $?digest
  39.     set digest = *
  40.     if $?interact
  41.     unset interact        # Assume non-interactive if no input list
  42.     endif
  43. else
  44.     set interact        # Note that this is interactive
  45.     if "X$digest" == X
  46.         set digest = *        # Default to all messages for empty input
  47.     else
  48.     $digest | set digest    # Pre-expand message numbers
  49.     endif
  50. endif
  51.  
  52. #
  53. # Suppress any "that isn't set" messages from "unset"
  54. #
  55. if $?warning
  56.     set savewarn
  57. endif
  58. unset warning oldpre oldpost oldindent oldign oldshow
  59.  
  60. #
  61. # Save everything in case the user wants it back.
  62. # Could wrap all this with "if $?interact" but this script
  63. # might be read by "mush -F", in which case we need this.
  64. #
  65. if $?pre_indent_str
  66.     set oldpre = "$pre_indent_str"
  67. endif
  68. if $?post_indent_str
  69.     set oldpost = "$post_indent_str"
  70. endif
  71. if $?indent_str
  72.     set oldindent = "$indent_str"
  73. endif
  74. if $?alwaysignore
  75.     set oldign = "$alwaysignore"
  76. endif
  77. if $?show_hdrs
  78.     set oldshow = "$show_hdrs"
  79. endif
  80. if $?quiet
  81.     set oldquiet = "$quiet"
  82. endif
  83. if $?no_expand
  84.     set savenoex
  85. endif
  86.  
  87. #
  88. # Prepare to form the digest.
  89. #
  90. set indent_str no_expand alwaysignore=include quiet=await,newmail
  91. unset post_indent_str
  92. alias DIGEST $thisfolder        # Any target in place of $thisfolder
  93. set pre_indent_str="--------"        # Insert your digest separator here
  94. set show_hdrs=from,date,subject        # Add any other headers you want
  95.  
  96. #
  97. # Now do it.  All that work for a two-line operation ....
  98. # NOTE: If you change DIGEST above, remove the "await" command here!
  99. # Backslashes prevent any cmd expansion from confusing us.
  100. #
  101. \delete $digest
  102. \mail -UH /dev/null -I $digest -s "Digest of $thisfolder" DIGEST; \await -T 1
  103.  
  104. #
  105. # Clean out the deleted stuff if not interactive
  106. #
  107. if ! $?interact
  108.     \update
  109. endif
  110.  
  111. #
  112. # Be neat and put everything back the way it was.
  113. #
  114. unset indent_str no_expand alwaysignore quiet pre_indent_str show_hdrs
  115. unalias DIGEST
  116. if $?savenoex
  117.     set no_expand
  118. endif
  119. if $?oldquiet
  120.     set quiet = "$oldquiet"
  121. endif
  122. if $?oldpre
  123.     set pre_indent_str = "$oldpre"
  124. endif
  125. if $?oldpost
  126.     set post_indent_str = "$oldpost"
  127. endif
  128. if $?oldindent
  129.     set indent_str = "$oldindent"
  130. endif
  131. if $?oldign
  132.     set alwaysignore = "$oldign"
  133. endif
  134. if $?oldshow
  135.     set show_hdrs = "$oldshow"
  136. endif
  137. unset oldpre oldpost oldindent oldign oldshow oldquiet nonoex digest
  138. if $?savewarn
  139.     unset savewarn
  140.     set warning
  141. endif
  142.